import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2022-10-02
 * Time:17:50
 */
class Student{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Test {

    public static void main(String[] args) {
        char []ch=new char[]{'a','b','c'};
        String str1=new String(ch);
        //String str3="abc";
        //System.out.println(str1 == str3);
        str1.intern();
        String str2="abc";
        System.out.println(str1 == str2);
    }
    public static void main1(String[] args) {
        //valueof转化其他类型成字符串
        String str=String.valueOf(123);
        //一个类转化成字符串
        Student student=new Student("ds",1);
        System.out.println(String.valueOf(student));

        //包装类
        //把字符串变成正数
        int ret =Integer.parseInt("123");

        //变大写
        String str1="dsadsa";
        String ret1=str1.toUpperCase();

        //变数组
        char[] ret2=str1.toCharArray();
        System.out.println(Arrays.toString(ret2));


        //格式化format
        String.format("%d","%d","%d",12,12,12);


        //替换
        //replace
        String str4="dsadsadsadsa";
        str4.replace("a","c");
        //替换一段字符
        str4.replace("ad","asd");

        //字符串拆分split
        String str3="sad&da&dwsad&das";
        String []ret3=str3.split("&");
        //分成两份
        String []ret4=str3.split("&",2);

        //转义字符，例如.可以这样书写\\.就行了，而\需要写成\\


        //截取的substring
        //左闭右开
        String str5="asdadsadsadsa";
        str5.substring(2);
        //截取的是左闭右开的，不包含左边，包含右边
        str5.substring(2,4);

        //去掉空格：trim方法，


        //是否包含：contains
    }
}
